home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: Compiler error on long multiplication?
- Date: 6 Feb 1996 16:18:08 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4f8gig$3uc@umbc9.umbc.edu>
- References: <4f4fr0$pea@newnews.iafrica.com>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Pieter Malan <vizier@iafrica.com> wrote:
- |> This code was compiled with 3.1.
-
- With 3.1 what? Is that a version of a compiler and if so what one...
-
- |> When compiled for 80386, the one onswer is wrong as indicated.
-
- Please elaborate...I do not see any printf() statements in your code
- which leads to my question of HOW you know the value of the incorrect
- variable.
-
- |> For all other processors the answer is correct. WHY??
-
- You mean you have compiled this code on every single processor currently
- known to exist? I doubt that ;-).
-
- Don't forget to #include <stdio.h> if you are doing any I/O.
-
- |> void main()
-
- Surely 'int main (void)' was intended.
-
- |> {
- |> unsigned long a; //OR SIGNED
-
- C++ comments are not supported on strict ANSI C compilers.
-
- |> unsigned long x;
- |>
- |> a = 1;
- |> x = (a * 100L) * 100L; // x = 13379344 WRONG!!!
-
- printf ("%lu\n", x); /* Gave me 10000 as expected */
-
- |> a = 100;
- |> x = a * 100L; // x = 10000
-
- More naughty C++ comments...
-
- printf ("%lu\n", x); /* Gave me 10000 as expected */
-
- return (0);
-
- |> }
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-